﻿package mortal.game.view.copy.petBreak
{
    import Message.DB.Tables.*;
    import Message.Game.*;
    import Message.Public.*;
    import fl.data.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.scene3D.map3D.util.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.view.copy.ChallengeCopy.view.*;
    import mortal.game.view.skill.*;

    public class PetBreakCopyUtil extends Object
    {
        public static const ENTER:int = 0;
        public static const SWEEP:int = 1;

        public function PetBreakCopyUtil()
        {
            return;
        }// end function

        public static function get petComboDp() : DataProvider
        {
            var _loc_3:SPet = null;
            var _loc_1:* = new DataProvider();
            var _loc_2:* = Cache.instance.pet.pets;
            for each (_loc_3 in _loc_2)
            {
                
                _loc_1.addItem({label:_loc_3.publicPet.name, value:_loc_3.publicPet.uid});
            }
            return _loc_1;
        }// end function

        public static function get maxPetIndex() : int
        {
            var _loc_2:SPet = null;
            var _loc_4:int = 0;
            var _loc_5:SPet = null;
            var _loc_1:int = -1;
            var _loc_3:* = Cache.instance.pet.pets;
            for each (_loc_5 in _loc_3)
            {
                
                if (_loc_2 == null || _loc_2 && _loc_2.publicPet.combat < _loc_5.publicPet.combat)
                {
                    _loc_2 = _loc_5;
                    _loc_1 = _loc_4;
                }
                if (_loc_5.publicPet.uid == Cache.instance.pet.fightPetUid)
                {
                    _loc_1 = _loc_4;
                    break;
                }
                _loc_4++;
            }
            return _loc_1;
        }// end function

        public static function getReward(param1:TPetBreakConfig) : Array
        {
            var _loc_2:Array = [];
            var _loc_3:int = 1;
            while (_loc_3 <= 4)
            {
                
                if (param1["itemIndex" + _loc_3] > 0)
                {
                    _loc_2.push(new ItemData(param1["itemIndex" + _loc_3]));
                }
                _loc_3++;
            }
            return _loc_2;
        }// end function

        public static function get petSkill() : Array
        {
            var _loc_5:SkillInfo = null;
            var _loc_1:Array = [];
            var _loc_2:* = Cache.instance.skill.getExSkillList();
            var _loc_3:* = _loc_2.length;
            var _loc_4:int = 0;
            while (_loc_4 < _loc_3)
            {
                
                _loc_5 = _loc_2[_loc_4];
                if (_loc_5 == null)
                {
                }
                else
                {
                    _loc_1.push(_loc_5.tSkill.series);
                }
                _loc_4++;
            }
            return _loc_1;
        }// end function

        public static function get baseSkill() : Array
        {
            var _loc_1:Array = [];
            var _loc_2:* = Cache.instance.pet.getSpetByUid(Cache.instance.pet.fightPetUid);
            var _loc_3:* = PetConfig.instance.getInfoByCode(_loc_2.publicPet.code);
            var _loc_4:* = new SSkill();
            _loc_4.skillId = _loc_3.normalSkill > 0 ? (_loc_3.normalSkill) : (70000000);
            _loc_4.cdDt = new Date();
            _loc_1.push(_loc_4);
            return _loc_1;
        }// end function

        public static function getChallengeTimeData(param1:int, param2:int) : ChallengeTimeData
        {
            var _loc_3:* = PetBreakConfig.instance.getItem(param1, param2);
            var _loc_4:* = new ChallengeTimeData();
            _loc_4.oneStarTime = _loc_3.star1Time;
            _loc_4.twoStarTime = _loc_3.star2Time;
            _loc_4.threeStarTime = _loc_3.star3Time;
            return _loc_4;
        }// end function

        public static function isPass(param1:int, param2:int) : Boolean
        {
            var _loc_3:* = Cache.instance.copy.petBreakCopy.petBreakInfo.floor;
            var _loc_4:* = Cache.instance.copy.petBreakCopy.petBreakInfo.level;
            return _loc_3 > param1 || _loc_3 == param1 && _loc_4 >= param2;
        }// end function

        public static function get player() : MovePlayer
        {
            var _loc_1:MovePlayer = null;
            if (GameMapUtil.curMapState.isPetBreakMap)
            {
                _loc_1 = ThingUtil.entityUtil.getSelfPetEntity();
            }
            else
            {
                _loc_1 = RolePlayer.instance;
            }
            if (_loc_1 == null)
            {
                _loc_1 = RolePlayer.instance;
            }
            return _loc_1;
        }// end function

        public static function get firstSkill() : SkillInfo
        {
            if (GameMapUtil.curMapState.isPetBreakMap)
            {
                return Cache.instance.skill.getExtSkillBySkillId(SSkill(PetBreakCopyUtil.baseSkill[0]).skillId);
            }
            return Cache.instance.skill.getFirstSkill();
        }// end function

        public static function getHPCost(param1:int) : int
        {
            if (param1 == 1)
            {
                return GameConst.PetBreakBuyHPFirstCost;
            }
            if (param1 == 2)
            {
                return GameConst.PetBreakBuyHPSecondCost;
            }
            if (param1 == 3)
            {
                return GameConst.PetBreakBuyHPThirdCost;
            }
            return GameConst.PetBreakBuyHPFourthCost;
        }// end function

        public static function get maxSweepTimes() : int
        {
            var _loc_1:* = Cache.instance.vip.level;
            if (_loc_1 > 0)
            {
                return GameConst.PetBreakMaxSweepTimes + int(VipConfig.instance.getValueByTypeAndLv(EVipRecordType._EVipRecordTypePetBreak, _loc_1));
            }
            return GameConst.PetBreakMaxSweepTimes;
        }// end function

    }
}
